package com.qfedu.bigdataapp.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.qfedu.bigdataapp.R;
import com.qfedu.bigdataapp.bean.HotVideo;

public class PlayHotVideoActivity extends AppCompatActivity {

    private ImageView imgBack, imgClose;
    private TextView tvTitle;
    private WebView wvHotVideo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_hot_video);

        //绑定控件
        imgBack = findViewById(R.id.img_back);
        imgClose = findViewById(R.id.img_close);
        tvTitle = findViewById(R.id.tv_video_title);
        wvHotVideo = findViewById(R.id.wv_hotvideo);

        //用于对浏览器进行设置的 对象
        WebSettings settings = wvHotVideo.getSettings();
        settings.setJavaScriptEnabled(true);//允许交互

        //获取到数据
        Intent intent = getIntent();
        HotVideo hotVideo = (HotVideo) intent.getSerializableExtra("video");
        //让webView加载 要播放的短视频链接
        tvTitle.setText(hotVideo.getTitle());//设置标题
        //https://www.douyin.com/video/7220621697517456672
        System.out.println(hotVideo.getShare_url());
        wvHotVideo.loadUrl(hotVideo.getShare_url());
    }
}